<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取数据库的文档集</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongoclient.listdbs.html">MongoClient::listDBs</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongoclient.selectdb.html">MongoClient::selectDB</a></div>
 <div class="up"><a href="class.mongoclient.html">MongoClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongoclient.selectcollection" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoClient::selectCollection</h1>
  <p class="verinfo">(PECL mongoclient &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">MongoClient::selectCollection</span> &mdash; <span class="dc-title">获取数据库的文档集</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongoclient.selectcollection-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.mongocollection.html" class="type MongoCollection">MongoCollection</a></span> <span class="methodname"><strong>MongoClient::selectCollection</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$db</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$collection</code></span>
   )</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongoclient.selectcollection-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>

      <em><code class="parameter">db</code></em>
     </dt>

     <dd>

      <p class="para">
       数据库名
      </p>
     </dd>

    
    
     <dt>

      <em><code class="parameter">collection</code></em>
     </dt>

     <dd>

      <p class="para">
       文档集名。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongoclient.selectcollection-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个新的文档集对象。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongoclient.selectcollection-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   如果数据库或文档集名称是无效的，抛出 <a href="class.exception.html" class="classname">Exception</a>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongoclient.selectcollection-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1377">
   <p><strong>Example #1 <span class="function"><strong>MongoClient::selectCollection()</strong></span> 例子</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$m&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$c1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"bar.baz"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;就等于<br /></span><span style="color: #0000BB">$c2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$m</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">selectDB</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">selectCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">"bar.baz"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;$c1&nbsp;和&nbsp;$c2&nbsp;现在表示的是同一个文档集<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongoclient.listdbs.html">MongoClient::listDBs</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongoclient.selectdb.html">MongoClient::selectDB</a></div>
 <div class="up"><a href="class.mongoclient.html">MongoClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
